package com.le.tester.webpage.masterCode.sortdemo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.google.common.collect.ImmutableList;

import java.util.Arrays;
import java.util.List;

/**
 * 描述：sort
 */
public class SortDemo {
    public String sortTarget;

    public SortDemo() {
    }

    public SortDemo(String sortTarget) {
        this.sortTarget = sortTarget;
    }

    public void testSort() {
        List<SortDemo> sorts = ImmutableList.of(
                new SortDemo("300"),
                new SortDemo("50"),
                new SortDemo("200"),
                new SortDemo("220"));
        //sort方法第一个传入的需要数组
        SortDemo[] sortDemos = new SortDemo[sorts.size()];
        sorts.toArray(sortDemos);
        System.out.println("排序之前：" + Arrays.toString(sortDemos));
        Arrays.sort(sortDemos, new NormalComparator());
        System.out.println("排序之后：" + Arrays.toString(sortDemos));
    }

    @Override
    public String toString() {
        return "SortDemo{" +
                "sortTarget='" + sortTarget + '\'' +
                '}';
    }

    public static void main(String[] args) {
        SortDemo sortDemo = new SortDemo();
        sortDemo.testSort();
    }


}
